<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./WEB-INF/templates/turnitup_template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="top">
        <ui:include src="./WEB-INF/templates/logo_bar.xhtml"/>
        <p:breadCrumb>
            <p:menuitem outcome="index"/>
            <p:menuitem value="#{webtext.my_account}" url="#" disabled="true"/>
        </p:breadCrumb>
    </ui:define>

    <ui:define name="menu_left">
        <h2>#{webtext.my_account}</h2>
        <hr/>
        
        <h:form prependId="false">
            <p:panelGrid columns="1">
                <p:commandLink update=":content_panel" styleClass="menu_item" value="#{webtext.my_data}" action="#{userController.prepareMyCustomerData}"/>
                <p:commandLink update=":content_panel" styleClass="menu_item" value="#{webtext.my_orders}" action="#{userController.prepareMyOrders}"/>
                <p:commandLink update="@all" styleClass="menu_item" value="#{webtext.logout}" action="#{userController.logout}"/>
            </p:panelGrid>  
        </h:form>
    </ui:define>

    <ui:define name="basket">
        <ui:include src="./WEB-INF/templates/basket_widget.xhtml"/>
    </ui:define>

    <ui:define name="content">
        <h:panelGroup layout="block" id="content_panel">    
            <h:form id="my_customerdata_form" rendered="#{userController.renderMyData}">
                <p:messages id="messages_mydata" showDetail="true" autoUpdate="true" closable="true" />
                <h:outputText styleClass="content_title" value="#{webtext.my_data}"/>
                
                <h:panelGrid id="updateCustomer" columns="3" cellpadding="3">
                    
                    <h:outputLabel value="#{webtext.name}" for="name" />
                    <p:inputText id="name" value="#{userController.selected.name}"/>
                    <p:message for="name"/>
                    
                    <h:outputLabel value="#{webtext.surname}" for="surname" />
                    <p:inputText id="surname" value="#{userController.selected.surname}"/>
                    <p:message for="surname"/>
                    
                    <h:outputLabel value="#{webtext.password}" for="pass_edit" />
                    <p:password id="pass_edit" value="#{userController.selected.password}" feedback="true" match="pass2_edit" validatorMessage="#{webtext.validation_password}"/>
                    <p:message for="pass_edit"/>
                    
                    <h:outputLabel value="#{webtext.password2}" for="pass2_edit" />
                    <p:password id="pass2_edit" value="#{userController.selected.password}"/>
                    <p:message for="pass2_edit"/>
                      
                    <h:outputLabel value="#{webtext.phone}" for="phone" />
                    <p:inputText type="number" id="phone" value="#{userController.selected.phone}" validatorMessage="#{webtext.validation_phone}">
                        <f:validateLength minimum="9" maximum="9"/>
                        <f:validateLongRange minimum="1"/>
                    </p:inputText>  
                    <p:message for="phone"/>
                    
                    <h:outputLabel value="#{webtext.address}" for="address" />
                    <p:inputText id="address" value="#{userController.selected.address}"/>
                    <p:message for="address"/>
                    
                    <h:outputLabel value="#{webtext.country}" for="country" />
                    <p:inputText id="country" value="#{userController.selected.country}"/>
                    <p:message for="country"/>
                    
                    <h:outputLabel value="#{webtext.city}" for="city" />
                    <p:inputText id="city" value="#{userController.selected.city}"/>
                    <p:message for="city"/>
                    
                    <h:outputLabel value="#{webtext.postal_code}" for="postal_code" />
                    <p:inputText type="number" id="postal_code" value="#{userController.selected.postalCode}" validatorMessage="#{webtext.validation_pcode}">
                        <f:validateLength minimum="5" maximum="5"/>
                        <f:validateLongRange minimum="1"/>
                    </p:inputText>
                    <p:message for="postal_code"/>        
                                        
                    <p:commandButton update="updateCustomer"  value="#{webtext.save}" action="#{userController.update}" icon="ui-icon-disk"/>
                    <p:commandButton type="reset" value="#{webtext.reset}"/>
                </h:panelGrid>
            </h:form>      
            
            <h:form id="my_customerorders_form" rendered="#{userController.renderMyOrders}">
                <h:outputText styleClass="content_title" value="#{webtext.my_orders}"/>                
            </h:form>
        </h:panelGroup>
    </ui:define>

    <ui:define name="footer">
        <ui:include src="./WEB-INF/templates/footer.xhtml"/>
    </ui:define>

</ui:composition>
